home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1995 #5 & #6 / Amiga Plus CD - 1995 - No. 5 and 6.iso / pd / netz / term / extras / source / gtlayout-source.lha / LTP_DrawBox.c < prev    next >
C/C++ Source or Header  |  1995-03-25  |  3KB  |  147 lines

  1. /*  GadTools layout toolkit
  2. **
  3. **  Copyright © 1993-1995 by Olaf `Olsen' Barthel
  4. **  Freely distributable.
  5. */
  6.  
  7. #include "gtlayout_global.h"
  8.  
  9. VOID __regargs
  10. LTP_DrawMultiLineButton(struct RastPort *RPort,WORD Left,WORD Top,WORD Width,WORD Height,struct ImageInfo *ImageInfo)
  11. {
  12.     WORD Len,ThisTop,ThisLeft;
  13.     STRPTR *Lines = ImageInfo -> Lines;
  14.     WORD LineCount = ImageInfo -> LineCount;
  15.     STRPTR KeyStroke = ImageInfo -> KeyStroke;
  16.  
  17.     ThisTop = Top + (Height - LineCount * RPort -> TxHeight) / 2 + RPort -> TxBaseline;
  18.  
  19.     do
  20.     {
  21.         Len = strlen(*Lines);
  22.  
  23.         ThisLeft = Left + (Width - TextLength(RPort,*Lines,Len)) / 2;
  24.  
  25.         Move(RPort,ThisLeft,ThisTop);
  26.         Text(RPort,*Lines,Len);
  27.  
  28.         if(KeyStroke)
  29.         {
  30.             if(KeyStroke >= *Lines && KeyStroke < *Lines + Len)
  31.             {
  32.                 ULONG OldStyle;
  33.  
  34.                 if(KeyStroke != *Lines)
  35.                     ThisLeft += TextLength(RPort,*Lines,(ULONG)KeyStroke - (ULONG)(*Lines));
  36.  
  37.                 OldStyle = SetSoftStyle(RPort,FSF_UNDERLINED,AskSoftStyle(RPort));
  38.  
  39.                 Move(RPort,ThisLeft,ThisTop);
  40.                 Text(RPort,KeyStroke,1);
  41.  
  42.                 SetSoftStyle(RPort,OldStyle & ~FSF_UNDERLINED,OldStyle);
  43.  
  44.                 KeyStroke = NULL;
  45.             }
  46.         }
  47.  
  48.         ThisTop += RPort -> TxHeight;
  49.         Lines++;
  50.     }
  51.     while(--LineCount);
  52. }
  53.  
  54. VOID __regargs
  55. LTP_DrawBox(struct RastPort *rp,struct DrawInfo *drawInfo,LONG left,LONG top,LONG width,LONG height,BOOLEAN selected,BOOLEAN ghosted,ImageInfo *imageInfo)
  56. {
  57.     UWORD        *pens = drawInfo -> dri_Pens;
  58.     UWORD         pen1,pen2,pen3,pen4;
  59.     ImageTypes     imageType = imageInfo -> ImageType;
  60.  
  61.     if(selected)
  62.     {
  63.         pen1 = SHADOWPEN;
  64.         pen2 = SHINEPEN;
  65.         pen3 = FILLPEN;
  66.         pen4 = FILLTEXTPEN;
  67.     }
  68.     else
  69.     {
  70.         pen1 = SHINEPEN;
  71.         pen2 = SHADOWPEN;
  72.         pen3 = BACKGROUNDPEN;
  73.         pen4 = TEXTPEN;
  74.     }
  75.  
  76.     LTP_SetPens(rp,pens[pen1],0,JAM1);
  77.     Move(rp,left + 1,top + 1);
  78.     Draw(rp,left + 1,top + height - 2);
  79.     Draw(rp,left,top + height - 1);
  80.     Draw(rp,left,top);
  81.     Draw(rp,left + width - 2,top);
  82.  
  83.     LTP_SetAPen(rp,pens[pen2]);
  84.     Move(rp,left + width - 2,top + height - 2);
  85.     Draw(rp,left + width - 2,top + 1);
  86.     Draw(rp,left + width - 1,top);
  87.     Draw(rp,left + width - 1,top + height - 1);
  88.     Draw(rp,left + 1,top + height - 1);
  89.  
  90.     LTP_SetAPen(rp,pens[pen3]);
  91.     RectFill(rp,left + 2,top + 1,left + 2 + width - 5,top + 1 + height - 3);
  92.  
  93.     LTP_SetAPen(rp,pens[pen4]);
  94.  
  95.     switch(imageType)
  96.     {
  97.         case IMAGECLASS_PICKER:
  98.         {
  99.             LONG    Left    = left + 4,
  100.                 Top    = top + 2,
  101.                 Width    = width - 8,
  102.                 Height    = height - 4;
  103.  
  104.             LTP_DrawPicker(rp,FALSE,Left,Top,Width,Height);
  105.             break;
  106.         }
  107.  
  108.         case IMAGECLASS_MULTILINEBUTTON:
  109.  
  110.             LTP_DrawMultiLineButton(rp,left + 4,top + 2,width - 8,height - 4,imageInfo);
  111.             break;
  112.  
  113.         case IMAGECLASS_LEFTINCREMENTER:
  114.         case IMAGECLASS_RIGHTINCREMENTER:
  115.  
  116.             LTP_DrawIncrementer(rp,imageType == IMAGECLASS_LEFTINCREMENTER,left + 2,top + 1,width - 4,height - 2);
  117.             break;
  118. #ifdef DO_TAPEDECK_KIND
  119.         case IMAGECLASS_BACKWARD:
  120.         case IMAGECLASS_FORWARD:
  121.         case IMAGECLASS_PREVIOUS:
  122.         case IMAGECLASS_NEXT:
  123.         case IMAGECLASS_RECORD:
  124.         case IMAGECLASS_PLAY:
  125.         case IMAGECLASS_STOP:
  126.         case IMAGECLASS_PAUSE:
  127.         case IMAGECLASS_EJECT:
  128.         case IMAGECLASS_REWIND:
  129.  
  130.             LTP_DrawTapeButton(rp,imageInfo,left,top,width,height,drawInfo -> dri_Resolution . X,drawInfo -> dri_Resolution . Y,pens[pen3]);
  131.             break;
  132. #endif    /* DO_TAPEDECK_KIND */
  133.     }
  134.  
  135.     if(ghosted)
  136.     {
  137.         if(width > 4 || height > 2)
  138.         {
  139.             LTP_SetAPen(rp,pens[BLOCKPEN]);
  140.  
  141.             SetAfPt(rp,(UWORD *)&ghostingPat,1);
  142.             RectFill(rp,left + 2,top + 1,left + width - 1 - 2,top + height - 1 - 1);
  143.             SetAfPt(rp,NULL,0);
  144.         }
  145.     }
  146. }
  147.